
/**
 * Local Storage 浏览器永久缓存
 */
export const Local = {
    /** 设置缓存 */
    set(key: string, val: any) {
        window.localStorage.setItem(key, JSON.stringify(val || ''));
    },
    /** 获取缓存 */
    get(key: string) {
        let result: any = window.localStorage.getItem(key);
        return result ? JSON.parse(result) : '';
    },
    /** 根据 key 移除缓存 */
    remove(key: string) {
        window.localStorage.removeItem(key);
    },
    /** 移除全部缓存 */
    removeAll() {
        window.localStorage.clear();
    }
};